_require local "../../../../basis.smi"
(* _require local "../../../libs/env/main/SEnv.smi" *)
_require local "../../../data/symbols/main/Loc.smi"
_require local "../../../data/symbols/main/Symbol.smi"
_require local "../../../data/symbols/main/RecordLabel.smi"
_require local "../../../extensions/debug/main/Bug.smi"
_require local "../../../libs/ids/main/LocalID.smi"

_require local "../../../data/control/main/Control.smi"
_require local "../../../compilerIRs/absyn/main/AbsynConst.smi"
(* _require local "../../../data/builtin/main/BuiltinPrimitive.ppg.smi" *)
_require local "../../../data/builtin/main/BuiltinTypes.smi"
(* _require local "../../../compilerIRs/idcalc/main/EvalIty.smi" *)
_require local "../../../data/types/main/Types.ppg.smi"
_require local "../../../data/types/main/TvarMap.smi"
_require local "../../../compilerIRs/patterncalc/main/PatternCalc.ppg.smi"
_require local "./CheckProvide.smi"
_require local "./EvalSig.smi"
_require local "./EvalTy.smi"
_require local "./FunctorUtils.smi"
_require local "./NameEvalError.ppg.smi"
_require local "./NameEvalInterface.smi"
_require local "./NameEvalUtils.smi"
_require local "./NormalizeTy.smi"
_require local "./SetLiftedTys.smi"
_require local "./SigCheck.smi"
_require local "./Subst.smi"
_require local "./TfunVars.smi"
_require local "./SpliceFunProvide.smi"
_require local "./RenameLongsymbol.smi"

_require "../../../compilerIRs/patterncalc/main/PatternCalcInterface.ppg.smi"
_require "../../../compilerIRs/absyn/main/InterfaceName.ppg.smi"

_require local "../../../extensions/usererror/main/UserErrorUtils.smi"
_require "../../../compilerIRs/idcalc/main/IDCalc.ppg.smi"
_require "../../../data/symbols/main/Loc.smi"
_require "../../../extensions/usererror/main/UserError.ppg.smi"
_require "../../analyzefiles/main/AnalyzeSource.smi"
_require "../../analyzefiles/main/Analyzers.smi"
_require "./NameEvalEnv.ppg.smi"
_require local "./NameEvalEnvPrims.smi"

structure NameEval =
  struct
    val nameEval : Loc.source
                   -> {topEnv: NameEvalEnv.topEnv, 
                      version: IDCalc.version,
                      systemDecls: IDCalc.icdecl list}
                   -> PatternCalcInterface.compile_unit
                   -> {requireTopEnv : NameEvalEnv.topEnv,
                       returnTopEnv : NameEvalEnv.topEnv,
                       icdecls : IDCalc.topdecl,
                       warnings : UserError.errorInfo list}

    val evalBuiltin
        : PatternCalcInterface.pitopdec list
          -> NameEvalEnv.topEnv * IDCalc.icdecl list

    val nameEvalInterface
        : NameEvalEnv.topEnv
          -> PatternCalcInterface.interface_unit
          -> NameEvalEnv.topEnv * UserError.errorInfo list
  end
